<?php include("inc/db_config.inc"); ?>
<?php 
$g_tab="blog";
$g_title="博客收录";
$g_header=""; 
$g_js='<script type="text/javascript">
	$(document).ready(function(){
	function getRecent(obj,zid,sid,ps,time){
	    obj.parent().show();
			obj.html("加载中...");
			var url="http://api.zhui.cn/content/List.json?zid="+zid+"&ActionID=1&SourceID="+sid+"&&CurrentPage=1&PageSize="+ps+"&jsoncallback=?";
			var errorTimer=setTimeout(function(){
				if($("#show")[0].innerHTML=="加载中..."){
				$("#show")[0].innerHTML="<span style=\"color:#f00;\">连接超时</span>";
										return false;
				}
			},time);
			$.getJSON(url,function(json){
				 if(errorTimer){
						 clearTimeout(errorTimer);
				 }
				var Status = json.StatusInfo.Status;
				if(Status==0){
						obj.html(json.StatusInfo.ReturnCode);
				}else{
					var ul=$("<ul/>");
              if(json.CItems){
											$.each(json.CItems,function(i,m){
																var Title=m.Title;
																var addDate=m.AddDate;
																var ImgUrl=m.ImgUrl;
																var li=$("<li/>");
																var a=$("<a target=\"_blank\" href=\""+ImgUrl+"\"/>");
																var span=$("<span/>");
																span.html(addDate);
																a.html(Title);
																li.append(a);
																						li.append(span);
																ul.append(li);
											})
											obj.empty().append(ul);
											var wh=$(window).height();
											var showH=$("#showwrap").height();
											$("#showwrap").css("top",(wh-showH)/2+"px");
											$("#showwrap").css("margin-top",0);
								}else{
											obj.html("暂未检测到更新内容!");
								}
             }
 				})
                
				}
				$(".blog_list li i").click(function(){
						var zid=$(this).attr("zid");
						var sid=$(this).attr("sid");
						var ps=$(this).attr("ps");
						$("#rec_title").html($(this).parent().find("a").eq(0).html());
						getRecent($("#show"),zid,sid,ps,30000);
				})               
				$("#rec_close").click(function(){
						$("#showwrap").hide();
				})
	})
</script>';
?>
        <?php include("header.php"); ?>
  
			<div class="crumb"><a href="index.php">首页</a>&gt;博客收录</div>
			<div class="main">
            <div id="showwrap" style="border:2px solid #444;width:280px;min-height:50px;display:none;position:fixed;left:50%;top:50%;margin:-25px 0 0 -140px;background:#fff;z-index:1000;padding:10px;line-height:1.8;"><div id="rec_title"></div><span id="rec_close" style="cursor: pointer;">close</span><div id="show"></div></div>
				<div class="article">
					<div class="conbox">
						<div class="cb_hd">
							<span class="cb_tl"></span>
							<span class="cb_tr"></span>
							<h2>博客收录</h2>
						</div>
						<div class="cb_bd">
							<div class="blog_info">
								<p style="margin:0 5px;color: #666;border:1px solid #bbb;padding:2px;line-height:18px;"><img src="i/tip_16.png"/>鼠标移到任意博客，点击右上角小图标，即可查看该博客最近更新列表。更新列表由 <a href="http://www.zhui.cn" target="_blank">追信</a> API提供</p>
								<div class="blog_cont">
									<ul class="blog_list">
									<?php
									function getPageInfo($sql, $ps, $currPage)
{
    global $beginNum, $begin, $end, $page, $totalpage;
    //分页开始
    $result = mysql_query($sql);
    //$all=mysql_fetch_array($rn);
    //$total=$all[0];//全部记录数目
    $total = mysql_num_rows($result);
    $pagesize = $ps;
    $page = $currPage;
    $totalpage = ceil($total / $pagesize);
    if ($page < 1) {
        $page = 1;
    }
    if ($page > $totalpage) {
        $page = $totalpage;
    }
    $begin = $page - 4;
    $end = $page + 5;
    if ($page < 5) {
        $begin = 1;
        $end = 10;
    }
    if ($page > $totalpage - 5) {
        $begin = $totalpage - 9;
        $end = $totalpage;
    }
    if ($begin < 1) {
        $begin = 1;
    }
    if ($end > $totalpage) {
        $end = $totalpage;
    }
    $beginNum = ($page - 1) * $pagesize;


    //分页结束
}
if (isset($_REQUEST['p']) && $_REQUEST['p'] != "") {
    $currPage = $_REQUEST['p'];
} else {
    $currPage = 1;
}
$pagesize = 40;
getPageInfo("select * from blogs inner join blog_cata on blogs.cata=blog_cata.id where blog_cata.status='1'", $pagesize, $currPage);


									?>
																<?php

$result_list = mysql_query("select title,links,description,z_zid,z_sid,z_ps,name from blogs,blog_cata where blogs.cata=blog_cata.id and blog_cata.status='1' order by blogs.id desc limit $beginNum,$pagesize");
if (mysql_affected_rows() > 0) {
    while ($row_list = mysql_fetch_array($result_list)) {
?>
										<li><a href="<?php echo $row_list['links']; ?>" target="_blank"><?php echo $row_list['title']; ?></a><span><?php echo $row_list['name']; ?></span><i zid="<?php echo $row_list['z_zid']; ?>" sid="<?php echo $row_list['z_sid']; ?>" ps="<?php echo $row_list['z_ps']; ?>" title="点击查看此博客最近文章列表" tabindex="-1">更新</i><?php if($row_list['description']!=""){ ?><div class="bdesc"><pre style="padding:5px;"><?php echo $row_list['description']; ?></pre></div><?php } ?></li>
										                            <?php }
} else { ?>
										<li>暂无博客</li>
										 <?php } ?>
									
									</ul>
									<div class="c"></div>
									<?php if ($totalpage > 1) { ?>
					<div class="pageinfo">
                    <a href="?p=1">首页</a>
								<a href="?p=<?php echo $page - 1; ?>">上一页</a>
                                <?php
    for ($i = $begin; $i <= $end; $i++) {
        if ($i == $page) {
            echo "&nbsp;<span>" . $i . "</span>";
        } else {
            echo "&nbsp;<a href='?p=$i'>" . $i . "</a>";
        }
    }
?>
								<a href="?p=<?php echo $page + 1; ?>">下一页</a>
                                <a href="?p=<?php echo $totalpage; ?>">尾页</a>
							</div><?php } ?>
								</div>
							</div>
							<div class="comments">
								
								
							</div>
						</div>
						<div class="cb_ft"></div>
					</div>
				</div>
			</div>
            
        <?php include("footer.php"); ?>